<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div id="app"></div>
    <div id="app1"></div>
    <div id="app2"></div>
    <script src="../js/babel.min.js"></script>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/prop-types.js"></script>
    <script type="text/babel">
      function Demo(props) {
        const { name, age, sex, date } = props;
        return (
          <ul>
            <li>姓名：{name}</li>
            <li>年龄：{age}</li>
            <li>性别：{sex}</li>
            <li>日期：{date}</li>
          </ul>
        );
      }
      // 设置校验规则
      Demo.propTypes = {
        name: PropTypes.string.isRequired,
        age: PropTypes.number,
        spack: PropTypes.func,
      };
      // 设置默认值
      Demo.defaultProps = {
        sex: "未知",
        date: Date(),
      };
      const p = { name: "张三", age: 18 };
      ReactDOM.render(<Demo {...p} />, document.getElementById("app1"));
    </script>
  </body>
</html>
